/*
 * ulc2xml.h -- generating xml-version of ulc-file reading the structure from it --
 *     written by Stanley J. Hong <babel96@gmail.com>, 2011.
 *
 *  This file is part of ULS, Unified Lexical Scheme.
 */

#ifndef __ULC2XML_H__
#define __ULC2XML_H__

#include "uls_config.h"
#include <stdio.h>

#define ULC2XML_WANT_EOF_TOK      0x0002
#define ULC2XML_CASE_INSENSITIVE  0x0010
#define ULC2XML_WANT_LF_CHAR      0x0020
#define ULC2XML_WANT_TAB_CHAR     0x0040

typedef struct _ulc_wordlist ulc_wordlist_t;
struct _ulc_wordlist {
	char *wordtext;
	struct _ulc_wordlist *next;
};

typedef struct _ulc_commtype ulc_commtype_t;
struct _ulc_commtype {
	char start_mark[ULS_COMM_MARK_MAXSIZ+1];
	char end_mark[ULS_COMM_MARK_MAXSIZ+1];
};

typedef struct _ulc_quotetype ulc_quotetype_t;
struct _ulc_quotetype {
	int  tok_id;
	char start_mark[ULS_QUOTE_MARK_MAXSIZ+1];
	char end_mark[ULS_QUOTE_MARK_MAXSIZ+1];
};

typedef struct _ulc_token_def ulc_token_def_t;
struct _ulc_token_def {
	int  tok_id;
	char name[ULS_LEXSTR_MAXSIZ+1];
	char keyword[ULS_LEXSTR_MAXSIZ+1];
};

#define ULC_ID_RANGE_TYPE_CHARSET  0
#define ULC_ID_RANGE_TYPE_RANGE    1

typedef struct _ulc_id_range ulc_id_range_t;
struct _ulc_id_range {
	int  type;
	char charset[ULS_LEXSTR_MAXSIZ+1];
};

typedef struct _ulc_file ulc_file_t;
struct _ulc_file {
	char filever[16];
	char ver[16];
	unsigned int flags;
	
	ulc_commtype_t commtypes[ULS_N_MAX_COMMTYPES];
	int n_commtypes;

	ulc_quotetype_t quotetypes[ULS_N_MAX_COMMTYPES];
	int n_quotetypes;

	ulc_id_range_t idfirst_charsets[ULS_N_CHARSET_RANGES];
	int n_idfirst_charsets;

	ulc_id_range_t id_charsets[ULS_N_CHARSET_RANGES];
	int n_id_charsets;

	ulc_token_def_t  *tokdef_list;
	int  n_tokdef_list, n_alloc_tokdef_list;
	int  tokid_seqnum;
};

extern ulc_file_t ulc_file;

extern ulc_wordlist_t* new_wordlist_element(char *text);
extern void release_wordlist(ulc_wordlist_t* wrdlst);
extern ulc_token_def_t* new_token_def(char *name, char* keyw, int tok_id);
extern void dump_ulc_file(ulc_file_t *ulc, FILE* fout);

#endif
